<?php
	require_once($_SERVER["DOCUMENT_ROOT"]."/global.php");
	require_once($_SERVER["DOCUMENT_ROOT"]."/modules/security_mod.php");
	require_once($_SERVER["DOCUMENT_ROOT"]."/alerter/modules/watched_mod.php");

	SecurityMod::login();

	$level = $_SESSION["account"]->getLevel();
	if ($level != "Admin" && $level != "AlertUser")
		SecurityMod::logout();
	
	$aid = $_SESSION["account"]->getName();
	$pageNumber = intval(v($_REQUEST, "page"));
	if ($pageNumber < 1)
		$pageNumber = 1;

	$id = v($_REQUEST, "id");
	$wtc = WatchedMod::getWatchedPilotById($id);

?>
<html>
<head>
<title><?php echo(SettingsMod::PAGE_TITLE." :: Edit Watched"); ?></title>
<link rel="stylesheet" href="main.css">
</head>
<body>

	<br />
	<h2 align="center">Edit watch list entry</h2>
	<form name="newEntry" method="post" action="watch_list_edit_confirm.php">
	<table background="<?php echo(SettingsMod::STATIC_IMAGES)?>/bgd.gif" class="messagestyle" align="center">
	<tr>
		<th>Pilot ID:</th>
		<td><input type="text" name="pilot_id" style="width: 100%" value="<?php echo($wtc->getPid()); ?>" /></td>
	</tr>
	<tr>
		<th>Pilot Name:</th>
		<td><input type="text" name="pilot" style="width: 100%" value="<?php echo($wtc->getName()); ?>" /></td>
	</tr>
	<tr>
		<th>Faction:</th>
		<td>
			<select name="faction" style="width: 100%" />
				<option value='Empire' <?php if($wtc->getFaction() == "Empire") echo("selected='selected'"); ?>>Empire</option>
				<option value='Union' <?php if($wtc->getFaction() == "Union") echo("selected='selected'"); ?>>Union</option>
				<option value='Neutral' <?php if($wtc->getFaction() == "Neutral") echo("selected='selected'"); ?>>Neutral</option>
				<option value='Federation' <?php if($wtc->getFaction() == "Federation") echo("selected='selected'"); ?>>Federation</option>
			</select>
		</td>
	</tr>
	<tr>
		<th>Alliance:</th>
		<td><input type="text" name="alliance" style="width: 100%" value="<?php echo($wtc->getAlliance()); ?>" /></td>
	</tr>
	<td>
		<input type="hidden" name="alerter" value="<?php echo($aid); ?>" style="width: 100%" />
		<input type="hidden" name="id" value="<?php echo($wtc->getId()); ?>" style="width: 100%" />
	</td>
	<tr>
		<td colspan="2" align="center"><input type="submit" value="Update" />&nbsp;<input type="button" value="Cancel" onclick="history.go(-1);" /></td>
	</tr>
	</table>
	</form>
</body>
</html>